package servlet;

import pojo.Product;
import sevice.ProductService;
import sevice.ProductServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author 郝雷蒙
 * @Description
 * @date 2020/11/26 10:48
 */
public class GotoSetOneproduct extends HttpServlet {
    private ProductService productService = new ProductServiceImpl();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");
        resp.setContentType("text/html");

        String did = req.getParameter("did");
        Product products = productService.getSetProductById(Integer.parseInt(did));
        req.setAttribute("products",products);
        req.getRequestDispatcher("set_product.jsp").forward(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }
}
